﻿Imports Oracle.DataAccess.Client
Public Class fListaMinRecargaPas
    Private lIdMin As String
    Public ReadOnly Property MinRecarga() As String
        Get
            Return lIdMin
        End Get
    End Property
    Private Sub btnConsultar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConsultar.Click
        Dim Conn As OracleConnection = New OracleConnection(My.Settings.ConnectionString)
        Dim cmd As OracleCommand = Conn.CreateCommand
        Dim qWhere As String = ""
        If Me.txtMinRecarga.Text.Trim.Length > 0 Then
            qWhere = "WHERE IDMIN LIKE '%" & Me.txtMinRecarga.Text & "%'"
        End If
        cmd.CommandText = "SELECT * FROM GLO_MINRECARGAPASATIEMPO " & qWhere
        Try
            Conn.Open()
            DsGlobal.GLO_MINRECARGAPASATIEMPO.Rows.Clear()
            DsGlobal.GLO_MINRECARGAPASATIEMPO.Load(cmd.ExecuteReader)
            Conn.Close()
            GLO_MINRECARGAPASATIEMPODataGridView.Focus()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

  
    Private Sub GLO_MINRECARGAPASATIEMPODataGridView_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles GLO_MINRECARGAPASATIEMPODataGridView.CellMouseDoubleClick
        If e.RowIndex >= 0 Then
            lIdMin = GLO_MINRECARGAPASATIEMPODataGridView.Rows(e.RowIndex).Cells("IDMIN").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub AsignaMinRecargaPasatiempo(ByVal Fila As Integer)
        If Fila >= 0 Then
            lIdMin = GLO_MINRECARGAPASATIEMPODataGridView.Rows(Fila).Cells("IDMIN").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub GLO_MINRECARGAPASATIEMPODataGridView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GLO_MINRECARGAPASATIEMPODataGridView.KeyDown
        If e.KeyData = Keys.Enter Then
            AsignaMinRecargaPasatiempo(GLO_MINRECARGAPASATIEMPODataGridView.CurrentRow.Index)
        End If
    End Sub
End Class